home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / spiele / publicdomain / scott / source / source.lha / amiga.c next >
C/C++ Source or Header  |  1996-07-29  |  3KB  |  94 lines

  1. /*
  2.  *  AMIGA Libs & Functions for Scott-Free
  3.  *
  4.  *  ===================================================================
  5.  *
  6.  *  Version History AMIGA:
  7.  *  Ver ,     Date,         Author, Comment
  8.  *  -------------------------------------------------------------------
  9.  *  1.0 , 28/07/96, Andreas Aumayr, First public release
  10.  *  ___________________________________________________________________
  11.  */
  12.  
  13.  
  14. #include <intuition/intuition.h>
  15.  
  16. struct IntuitionBase *IntBase;
  17. struct Screen *WBscreen;
  18. struct Window *win;
  19. struct DrawInfo *WBdrawinfo;
  20.  
  21.  
  22. BOOL open_libs(void)
  23. {
  24.         IntBase = (struct IntuitionBase *) OpenLibrary("intuition.library",37);
  25.         if (IntBase == NULL) {
  26.                 printf("Problems opening Intuition-Lib!\n");
  27.                 return(FALSE);
  28.         }
  29.         return(TRUE);
  30. }
  31.  
  32. void close_libs(void)
  33. {
  34.         FreeScreenDrawInfo(WBscreen,WBdrawinfo);
  35.         UnlockPubScreen(NULL,WBscreen);
  36.         if (IntBase != NULL) CloseLibrary(IntBase);
  37. }
  38.  
  39. void close_all(void)
  40. {
  41.         close_libs();
  42.         Close(act_hdl);
  43.         Close(env_hdl);
  44. }
  45.  
  46. struct FileHandle *Open_CON(char *type, int left_off, int top_off, int width, int height, char *title, char *flags)
  47. {
  48.         sprintf(str_buf,"%s:%d/%d/%d/%d/%s/%s",type,left_off,top_off,width,height,title,flags);
  49.         CON_handle = (struct FileHandle *) Open(str_buf,MODE_NEWFILE);
  50.         if (!CON_handle) {
  51.                 printf("Failed to open console window '%s'!\n",title);
  52.                 close_libs();
  53.                 exit(99);
  54.         }
  55.         else return(CON_handle);
  56. }
  57.  
  58. void AMIGA_init(void)
  59. {
  60.         WORD s_height,s_width,w_height_env,w_height_act,w_width,w_left,w_top;
  61.  
  62.         if (open_libs() == FALSE) exit(255);
  63.  
  64.         WBscreen = (struct Screen *) LockPubScreen(NULL);
  65.         WBdrawinfo = (struct DrawInfo *) GetScreenDrawInfo(WBscreen);
  66.         s_height = (WORD) WBscreen->Height;
  67.         s_width = (WORD) WBscreen->Width;
  68.  
  69.         win = WBscreen->FirstWindow;
  70.         w_width = (WORD) (Width * (UWORD) win->IFont->tf_XSize + 2 * 4);
  71.         w_height_env = (WORD) (TopHeight * (UWORD) win->IFont->tf_YSize + (BYTE) WBscreen->BarHeight + 4);
  72.         w_height_act = (WORD) (BottomHeight * (UWORD) win->IFont->tf_YSize + (BYTE) WBscreen->BarHeight + 4);
  73.         w_left = (WORD) (s_width - w_width) / 2;
  74.         w_top = (WORD) (s_height - w_height_env - w_height_act) / 2;
  75.  
  76.         if ((w_width > s_width) || ((w_height_env+w_height_act) > s_height)) {
  77.                 printf("Windows are to big for screen!\nTry the -t parameter.\n");
  78.                 close_libs();
  79.                 exit(20);
  80.         }
  81.  
  82.         env_hdl = Open_CON("RAW",w_left,w_top,w_width,w_height_env,"Environment","NOSIZE");
  83.         clrsys();
  84.         background(BLUE);
  85.         textcolor(WHITE,BLUE);
  86.         cursor(FALSE);
  87.         act_hdl = Open_CON("CON",w_left,w_top+w_height_env,w_width,w_height_act,"SCOTT-Free AMIGA","NOSIZE");
  88.         clrsys();
  89.         background(GREY);
  90.         textcolor(BLACK,GREY);
  91.         cursor(FALSE);
  92. }
  93.  
  94.